import torch
import h5py
import torch.utils.data as data
import random
from .database import Database
import utils.utils as utils
class Shark(Database):
    def __init__(self,flag='train'):
         self.height = 1088
         self.width = 1920 
         self.Znear=1380.0
         self.Zfar=3800.0
         self.framnumber=98
         self.traincames=range(10, 156)
         self.testcames=range(156, 193)
         self.cames=range(10,193)
         if utils.ip=='176':
            self.h5path='/data1/kaixindata/h5data/shark/shark{:0>3d}.h5'
         if utils.ip=='175':
            self.h5path='/data2/kaixindata/h5data/shark/shark{:0>3d}.h5'  #数据集不太对
         self.flag=flag
         super(Shark, self).__init__(flag)
    def getdata(self,cames,fram):
        cams1='cam{}'.format(cames)
        with h5py.File(self.h5path.format(cames),'r') as f:
            mask=torch.from_numpy(f[cams1]['mask'][fram]).unsqueeze(0)
            pictureL=torch.from_numpy(f[cams1]['imgL'][fram]) #名称为image 
            pictureR =torch.from_numpy(f[cams1]['imgR'][fram]) #名称为image
            dpointL =torch.from_numpy(f[cams1]['Lerror'][fram])  #名称为image
            dpointR=torch.from_numpy(f[cams1]['Rerror'][fram]) #名称为image
            target=torch.from_numpy(f[cams1]['target'][fram])  #名称为image
        return mask,pictureL,pictureR,dpointL,dpointR,target